import time

from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver import ActionChains
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_input import PointerInput

from comm.action import *
driver=CommonDriver.get_driver()

el1 = driver.find_element(by=AppiumBy.ID, value="com.dangdang.buy2:id/tv_sure")
el1.click()
el2 = driver.find_element(by=AppiumBy.ID, value="com.dangdang.buy2:id/tv_sure")
el2.click()
el3 = driver.find_element(by=AppiumBy.ID, value="com.android.packageinstaller:id/permission_allow_button")
el3.click()
time.sleep(5)
el4 = driver.find_element(by=AppiumBy.ID, value="com.dangdang.buy2:id/dialog_cancel_tv")
el4.click()
el5 = driver.find_element(by=AppiumBy.ID, value="com.dangdang.buy2:id/tv_sure")
el5.click()
el6 = driver.find_element(by=AppiumBy.ID, value="com.android.packageinstaller:id/permission_allow_button")
el6.click()


# el6 = driver.find_element(by=AppiumBy.XPATH, value="(//android.widget.ImageView[@resource-id=\"com.dangdang.buy2:id/icon_iv\"])[10]")
# el6.click()
# time.sleep(5)
# actions = ActionChains(driver)
# actions.w3c_actions = ActionBuilder(driver, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
# actions.w3c_actions.pointer_action.move_to_location(201, 518)
# actions.w3c_actions.pointer_action.pointer_down()
# actions.w3c_actions.pointer_action.pause(0.1)
# actions.w3c_actions.pointer_action.release()
# actions.perform()
time.sleep(2)
driver.swipe(152,192,486,201)